Skip to content

fix: timed calibration lost on reconfigure reload (v1.3.1)#8

Merged
hrabbach merged 1 commit into
mainfrom
gsd/fix-cal-reload-race
Jun 26, 2026
Merged

fix: timed calibration lost on reconfigure reload (v1.3.1)#8
hrabbach merged 1 commit into
mainfrom
gsd/fix-cal-reload-race

Conversation

@hrabbach

Copy link
Copy Markdown
Owner

Summary

Fixes a regression in v1.3.0 where a calibrated timed (non-bidirectional) motor drives to a target position using the 60s default travel time instead of the calibrated time — observed as a 25% close running ~15s (0.25 × 60) instead of ~6.25s (0.25 × 25).

Root cause

The timed-calibration flow aborts with reconfigure_successful, which makes Home Assistant reload the config entry and rebuild the cover from the calibration Store. The cover persisted calibration via a fire-and-forget hass.async_create_task(_save_calibration(...)), which raced the reload — so the rebuilt cover read an empty Store and fell back to DEFAULT_TRAVEL_TIME (60s). (Confirmed empirically: the user saw the entity flicker on save = the reload.)

Fix

options_flow_timed_calibration._emit_calibration_signal now awaits _save_calibration(...) to the Store before emitting the signal and before the reconfigure abort, so the write is durable by the time HA reloads and rebuilds the cover. Mirrors the bidirectional flow. Root-cause fix at the calibration source, not the symptom.

Tests

  • New regression test tests/test_cover.py::test_timed_calibration_survives_reconfigure_reload drives the real calibrate → reload-rebuild → set-position path (the prior test set _travel_time_open directly and missed this). RED before the fix, GREEN after.
  • Full suite: 208 passed (was 207, +1), ruff + mypy clean.

Patch release: 1.3.0 → 1.3.1.

🤖 Generated with Claude Code

The timed-calibration flow aborted with reconfigure_successful, which
reloads the config entry and rebuilds the cover from the calibration
Store. The cover's _save_calibration was fire-and-forget and raced the
reload, so the rebuilt cover read an empty Store and fell back to
DEFAULT_TRAVEL_TIME (60s) — a drive-to-% then used 60s instead of the
calibrated time. _emit_calibration_signal now awaits _save_calibration
before emitting the signal and aborting, so the Store is durable when
the reload rebuilds the cover. Adds a regression test exercising the
full calibrate -> reload-rebuild -> set-position path.
@hrabbach hrabbach merged commit b1fb26c into main Jun 26, 2026
1 check passed
@hrabbach hrabbach deleted the gsd/fix-cal-reload-race branch June 26, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant